package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCSaleCommissionPayment;
import com.shrct.businessprocess.project.RCSaleCommissionPayment4SettlementYear;
import com.shrct.businessprocess.project.impl.RCSaleCommissionPaymentImpl;
import com.shrct.businessprocess.project.proxy.RCSaleCommissionPayment4SettlementYearProxy;
import edu.fudan.mylang.common.NumberExtensions;
import edu.fudan.mylang.pf.BaseModelObject;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.DoubleExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCSALECOMMISSIONPAYMENT4SETTLEMENTYEAR_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcsalecommissionpayment4settlementyear")
public abstract class RCSaleCommissionPayment4SettlementYearImpl extends BaseModelObject implements RCSaleCommissionPayment4SettlementYear {
  public RCSaleCommissionPayment4SettlementYearImpl() {
    super();
  }
  
  public RCSaleCommissionPayment4SettlementYearImpl(final RCSaleCommissionPayment payment) {
    super();
    this.payment = payment;
  }
  
  @JoinColumn(name = "payment_id")
  @ManyToOne(targetEntity = RCSaleCommissionPaymentImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCSaleCommissionPayment payment;
  
  public RCSaleCommissionPayment getPayment() {
    return this.payment;
  }
  
  public RCSaleCommissionPayment4SettlementYear setPayment(final RCSaleCommissionPayment payment) {
    this.payment = payment;
    return this;			
    
  }
  
  private Double commissionAmount = Double.valueOf(0d);
  
  public Double getCommissionAmount() {
    return this.commissionAmount;
  }
  
  public RCSaleCommissionPayment4SettlementYear setCommissionAmount(final Double commissionAmount) {
    this.commissionAmount = commissionAmount;
    return this;			
    
  }
  
  private Double overflowCommissionAmount = Double.valueOf(0d);
  
  public Double getOverflowCommissionAmount() {
    return this.overflowCommissionAmount;
  }
  
  public RCSaleCommissionPayment4SettlementYear setOverflowCommissionAmount(final Double overflowCommissionAmount) {
    this.overflowCommissionAmount = overflowCommissionAmount;
    return this;			
    
  }
  
  private Double teamPrizeAmount = Double.valueOf(0d);
  
  public Double getTeamPrizeAmount() {
    return this.teamPrizeAmount;
  }
  
  public RCSaleCommissionPayment4SettlementYear setTeamPrizeAmount(final Double teamPrizeAmount) {
    this.teamPrizeAmount = teamPrizeAmount;
    return this;			
    
  }
  
  private Double com2 = Double.valueOf(0d);
  
  public Double getCom2() {
    return this.com2;
  }
  
  public RCSaleCommissionPayment4SettlementYear setCom2(final Double com2) {
    this.com2 = com2;
    return this;			
    
  }
  
  private Double tax = Double.valueOf(0d);
  
  public Double getTax() {
    return this.tax;
  }
  
  public RCSaleCommissionPayment4SettlementYear setTax(final Double tax) {
    this.tax = tax;
    return this;			
    
  }
  
  public Double getCom1() {
    Double _totalAmount = this.getTotalAmount();
    double _minus = DoubleExtensions.operator_minus(_totalAmount, this.com2);
    return Double.valueOf(_minus);
  }
  
  public Double getNetCom1() {
    Double _com1 = this.getCom1();
    double _minus = DoubleExtensions.operator_minus(_com1, this.tax);
    return Double.valueOf(_minus);
  }
  
  public Double getNetCom() {
    Double _netCom1 = this.getNetCom1();
    double _plus = DoubleExtensions.operator_plus(_netCom1, this.com2);
    return Double.valueOf(_plus);
  }
  
  /**
   * 本期佣金
   */
  public Double getTotalAmount() {
    Double _nullsafe = NumberExtensions.nullsafe(this.commissionAmount);
    Double _nullsafe_1 = NumberExtensions.nullsafe(this.overflowCommissionAmount);
    double _plus = DoubleExtensions.operator_plus(_nullsafe, _nullsafe_1);
    Double _nullsafe_2 = NumberExtensions.nullsafe(this.teamPrizeAmount);
    double _plus_1 = (_plus + (_nullsafe_2).doubleValue());
    return Double.valueOf(_plus_1);
  }
  
  public void update(final Procedure1<? super RCSaleCommissionPayment4SettlementYear> updater) {
    updater.apply(this);
    this.checkValid();
  }
  
  public RCSaleCommissionPayment4SettlementYearProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCSaleCommissionPayment4SettlementYearProxy proxy = new com.shrct.businessprocess.project.proxy.RCSaleCommissionPayment4SettlementYearProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
